/*
 * @Author: duanguang
 * @Date: 2020-11-26 22:23:23
 * @LastEditTime: 2022-04-29 14:51:52
 * @LastEditors: duanguang
 * @Description: 
 * @FilePath: /legions-server/app/router.ts
 * 「扫去窗上的尘埃，才可以看到窗外的美景。」
 */
import { Application } from 'egg';
/* import * as bodyparser from 'koa-bodyparser'; */
export default (app: Application) => {
  const { controller, router, jwt } = app;

  router.get('/', controller.home.index);
  router.post('/login', controller.user.login);
  router.post('/register', controller.user.register);
  router.post('/user/add', controller.user.addUser);
  router.post('/user/edit', controller.user.editUser);
  router.post('/user/delete', controller.user.deleteUser);
  router.get('/user/query', controller.user.queryUser);
  router.get('/user/getUserInfo', controller.user.getUserInfo);
  router.post('/user/password/resetDefault', controller.user.resetDefaultPwd);
  router.post('/user/password/update', controller.user.updateUserPwd);
  router.post('/user/email/update', controller.user.updateUserEmail);
  router.get('/user/baseInfo/query', controller.user.queryUserBaseInfo);
  router.post('/user/baseInfo/update', controller.user.updateUserBaseInfo);
  router.get('/user/safeInfo/query', controller.user.queryUserBaseInfo);
  router.get('/system/userList/query', controller.user.queryUserList);
  router.get('/monitor/errorList/query', controller.monitor.queryMonitorErrorList);
  router.get('/monitor/logList/query', controller.monitor.queryMonitorLogList);

  /** --------- jenkins ------------ */
  router.post('/jenkins/common', jwt as any, controller.jenkins.common);
  router.post('/jenkins/multipleBuilds', jwt as any, controller.jenkins.multipleBuilds);
  router.get('/jenkins/getBuildQueue', jwt as any, controller.jenkins.getBuildQueue);
  router.get('/jenkins/getExecutors', jwt as any, controller.jenkins.getExecutors);
  router.post('/jenkins/getPogressiveHtml', jwt as any, controller.jenkins.getPogressiveHtml);
  router.post('/jenkins/task/createOrModify', jwt as any, controller.jenkins.createOrModify);
  router.post('/jenkins/task/list', jwt as any, controller.jenkins.taskList);
  router.post('/jenkins/task/detail', jwt as any, controller.jenkins.detail);
  router.post('/jenkins/task/delete', jwt as any, controller.jenkins.delete);
  router.post('/jenkins/task/createOrModify', jwt as any, controller.jenkins.createOrModify);
  router.post('/jenkins/task/merge', jwt as any, controller.jenkins.merge);
  router.post('/jenkins/plan/createOrModify', controller.jenkins.createOrModifyPlan);
  router.post('/jenkins/plan/list', jwt as any, controller.jenkins.planList);
  router.post('/jenkins/plan/detail', jwt as any, controller.jenkins.planDetail);
  router.post('/jenkins/plan/delete', jwt as any, controller.jenkins.planDelete);
  router.post('/jenkins/plan/changeStatus', jwt as any, controller.jenkins.changePlanStatus);

  /** --------- sandbox ------------ */
  router.post('/sandbox/list', jwt as any, controller.sandbox.list);
  router.post('/sandbox/createOrModify', jwt as any, controller.sandbox.createOrModify);
  router.post('/sandbox/detail', jwt as any, controller.sandbox.detail);
  router.post('/sandbox/delete', jwt as any, controller.sandbox.delete);
  router.get('/sandbox/getScript', controller.sandbox.getScript);
  router.post('/sandbox/dispatchList', jwt as any, controller.sandbox.dispatchList);
  router.post('/sandbox/dispatchDetail', jwt as any, controller.sandbox.dispatchDetail);
  router.post('/sandbox/dispatchCreateOrModify', jwt as any, controller.sandbox.dispatchCreateOrModify);
  router.post('/sandbox/dispatchDelete', jwt as any, controller.sandbox.dispatchDelete);

  router.post('/repo/add',jwt as any, controller.repositoryProject.add)
  router.post('/repo/update',jwt as any, controller.repositoryProject.update)
  router.get('/repo/list',jwt as any, controller.repositoryProject.list)
  router.get('/branch/list', controller.branch.index)
  router.post('/branch/apply',jwt as any, controller.branch.apply)
  router.get('/branch/apply/list',jwt as any, controller.branch.list)
  router.get('/branch/apply/checkout',jwt as any, controller.branch.checkout)
  router.post('/branch/apply/delete',jwt as any, controller.branch.delete)
  router.post('/branch/apply/reject',jwt as any, controller.branch.reject)
  router.post('/branch/apply/update',jwt as any, controller.branch.update)
  router.post('/branch/merge/request',jwt as any, controller.branchMergeRequest.create)
  router.put('/branch/merge/request',jwt as any, controller.branchMergeRequest.update)
  router.put('/branch/merge/request/merge',jwt as any, controller.branchMergeRequest.approved)
  router.get('/branch/merge/request',jwt as any, controller.branchMergeRequest.list)
  router.get('/gitlab/authorization/login', controller.gitlab.oauthTokenLogin)
  router.get('/gitlab/projects', controller.gitlab.projects)
  router.post('/gitlab/projects', controller.gitlab.create_projects)
  router.get('/gitlab/groups', controller.gitlab.groups)
  // @ts-ignore
  /* app.io.route('send', app.io.controller.author.index); */
  // @ts-ignore
  app.io.of('/socket/directive').route('send',app.io.controller.directive.index);
  // @ts-ignore
  app.io.of('/io/init').route('send', app.io.controller.initProject.index);
};
